<?php

namespace app\hospital\controller;

use app\BaseController;
use app\hospital\model\doctor;
use app\hospital\model\doctoruser;
use think\facade\Db;
use think\facade\Request;
use think\facade\View;
class du extends BaseController
{
    function list(){
        $key=Request::param('key');
        $d=new doctoruser();
        if(!empty($key)){
            $data=$d->search();
        }else{
            $data=Db::table('doctoruser')->paginate(5);
        }
        View::assign('data',$data);
        return View::fetch();
    }
    function update(){
        $data=Request::post();
        $d=new doctoruser();
        $res=$d->update($data);
//        dump($data);
//      $res=Db::table('doctor')->update($data);
//        dump($res);
        if(!empty($res)){
            return 1;
        }else{
            return 0;
        }
//        return ($res);
    }
    function edit(){
        $num=Request::get('id');
        $d=new doctoruser();
//        $data=$d->find($num);
        $data=Db::table('doctoruser')->find($num);
        return json($data);
    }
    public function del(){
        $id=Request::param('id');
//        $d=new subjecttype();
        $res=Db::table('doctoruser')->where('num',$id)->delete();
//        $res=$d->del();
        if(!empty($res)){
            return 1;
        }else{
            return 0;
        }
//        dump($res);
//        return $res;
    }
}